/*
 * @Author: ray ray.chin@163.com
 * @Date: 2022-01-14 13:36:46
 * @LastEditors: ray ray.chin@163.com
 * @LastEditTime: 2024-06-14 11:52:39
 * @FilePath: /app-template-uni-upgrade/src/utils/login.js
 * @Description: 登录
 * 
 * Copyright (c) 2024 by ray, All Rights Reserved.
 */
import {
	gcj02towgs84
} from './bd0911toWGS84.js'
import randomWord from './randomWord';
import store from '@/store'
import api from '@/../api/api.js'
import md5 from 'blueimp-md5';

import { setStorageToken, getStorageToken } from "./storageHelper.js";


/**
 * @description: 账户+密码登录
 */
export function loginWithPassword (userId, password) {
    let ps = md5(btoa(userId) + password);
    return new Promise((resolve, reject) => {
        // 模拟登录
        store.commit("update", {
            loginData: {},
        });
        setStorageToken("loginToken", "testcode");
        resolve({success: true});
        // api.loginWithPassword({
        //     'password': ps,
        //     'userid': userId,
        // }, ).then(resp => {
        //     if (resp.code == 200 && resp.state && resp.data.loginCode == '00') {
        //         store.commit("update", {
        //             loginData: resp.data,
        //         });
        //         setStorageToken("loginToken", store.state.loginData.accessToken);
        //         resolve({success: true});
        //     } else {
        //         uni.showToast({
        //             title: resp.data.loginMsg || "系统异常，请联系管理员",
        //             icon: 'none'
        //         });
        //         resolve({success: false});
        //     }
        // });
	})
}